import argparse
import sys

import maven_cmd


def cmd_switch():
    parser = argparse.ArgumentParser(description='切换maven命令, 例如配置不同的jdk版本的maven mvn(jdk1.8) mvnn(jdk21) ')
    parser.add_argument('-c', nargs='?', default='', help='-c 设置命令')
    args, unknown_args = parser.parse_known_args()
    cmd = args.c
    if len(cmd) == 0 and len(unknown_args) > 0:
        cmd = unknown_args[0]
    else:
        cmd = "mvn"
    maven_cmd.switch_maven_cmd(cmd)
    print(f"switch to {cmd} successful!")


def jdk_switch():
    maven_cmd.set_jdk()


if __name__ == '__main__':
    argv = sys.argv
    if len(argv) == 1:
        jdk_switch()
    else:
        cmd_switch()
